﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Grishko.DataTier;
using OutdoorLib.BaseEntity.Agency;
using Grishko.SerilizeTools;
using System.ComponentModel;

namespace OutdoorLib.BaseEntity.Constraction
{
    /// <summary>
    /// Сторона носителя
    /// </summary>
    [TagNameInfo(TagName = "Side")]
    public class Side : SqlAgencyEntity
    {
        /// <summary>
        /// Вернуть ID конструкции владельца на основании данных о ее стороне
        /// </summary>
        /// <returns></returns>
        public static string GetConstractionID(string SideID)
        {
            string SQL = "select top 1 ObjectID from dbo.vSrchObjectPropertyStorage where TagName ='Constraction' and PropertyValue ='{0}'";
            object result = SqlTools.ExecuteSqlText(string.Format(SQL, SideID));
            if (null == result)
                return string.Empty;

            return result.ToString();


        }


        private string _Litera= string .Empty ;
        
        [SrchItemInfo(TxtPropertyName = "Литера")]
        public string Litera { get { return _Litera; } set { _Litera = value; } }


        [DefaultValue(0)]
        [SrchItemInfo(TxtPropertyName = "GRP")]
        public decimal GRP { get; set; }

        [DefaultValue(0)]
        [SrchItemInfo(TxtPropertyName = "OTS")]
        public decimal OTS { get; set; }


        [SrchItemInfo(TxtPropertyName = "Описание")]
        public string Direction { get; set; }

        [SrchItemInfo(TxtPropertyName = "Расстояние видимости")]
        public int LookDistance { get; set; }

        int _SurfaceCount = 1;
        [SrchItemInfo(TxtPropertyName = "Кол-во поверхностей")]
        public int SurfaceCount 
        { get { return _SurfaceCount; } 
            set { _SurfaceCount = value; } }
        
        private PriceList _PriceList = new PriceList();
        public PriceList PriceList { get { return _PriceList; } set { _PriceList = value; } }

        [SrchItemInfo(TxtPropertyName = "Цена", SqlFunctionText = "dbo.GetCurrentPrice(@CurrentPrice)")]
        public int CurrentPrice
        {
            get;
            set;
        }
    }
}
